﻿Public Class Security

    Public Shared Function Assert(ByVal Extension As ServerExtension, ByVal Connection As ServerConnection) As Boolean

        Dim allow = False
        'pull the security descriptor off the attribute
        For Each attr As Attribute In Extension.MethodInstance.GetCustomAttributes(False)
            If (TypeOf (attr) Is SecurityRoleAttribute) Then
                Dim sec As SecurityRoleAttribute = DirectCast(attr, SecurityRoleAttribute)
                If Not (sec Is Nothing) Then
                    If (sec.RoleName = "" OrElse Connection.UserInfo.IsInRole(sec.RoleName)) Then
                        allow = True
                        Exit For
                    End If
                End If
            End If
        Next
        Return allow
    End Function

End Class
